home *** CD-ROM | disk | FTP | other *** search
- on setAlienConstants
- global alienData, alienSO, maxAliens, laserSO, maxLasers
- alienSO = 400
- maxAliens = 1
- laserSO = 500
- maxLasers = 25
- end
-
- on initializeAliens
- global alienData, alienSO, maxAliens, wTest
- alienData = []
- repeat with wItem = 1 to maxAliens
- wSprite = wItem + alienSO - 1
- add(alienData, [0, point(random(5800), random(4400))])
- puppetSprite(wSprite, 1)
- set the member of sprite wSprite to "Alien1"
- set the loc of sprite wSprite to point(-50, -50)
- set the ink of sprite wSprite to 36
- end repeat
- wTest = 0
- end
-
- on initializelasers
- global laserData, laserSO, maxLasers, wTest
- laserData = []
- repeat with wItem = 1 to maxLasers
- wSprite = wItem + laserSO - 1
- add(laserData, [0, point(random(5800), random(4400))])
- puppetSprite(wSprite, 1)
- set the member of sprite wSprite to "Alien1"
- set the loc of sprite wSprite to point(-50, -50)
- set the ink of sprite wSprite to 36
- end repeat
- wTest = 0
- end
-
- on addAlien
- global alienData, alienSO, maxAliens, wTest
- case random(2) of
- 1:
- spawnloc = point([0, 5800][random(2)], random(4400))
- 2:
- spawnloc = point(random(5800), [0, 4400][random(2)])
- end case
- validSlot = 0
- repeat with wS = 1 to maxAliens
- if validSlot = 0 then
- if alienData[wS][1] = 0 then
- validSlot = wS
- end if
- end if
- end repeat
- if validSlot <> 0 then
- alienData[validSlot] = [1, spawnloc, random(360), random(360), 100]
- end if
- end
-
- on addLaser spawnloc, spawnAim
- global laserData, laserSO, maxLasers, wTest
- validSlot = 0
- repeat with wS = 1 to maxLasers
- if validSlot = 0 then
- if laserData[wS][1] = 0 then
- validSlot = wS
- end if
- end if
- end repeat
- if validSlot <> 0 then
- laserData[validSlot] = [1, spawnloc, spawnAim]
- sprite(laserSO + validSlot).rotation = spawnAim
- end if
- end
-
- on runAliens
- global alienData, alienSO, maxAliens, bgOffset, wTest, playerData, totalAliens, playerScore
- totalAliens = 0
- repeat with wAlien = 1 to maxAliens
- if alienData[wAlien][1] = 1 then
- totalAliens = totalAliens + 1
- wSprite = wAlien + alienSO - 1
- aLoc = alienData[wAlien][2]
- mloc = playerData[2]
- turnAdjust = random(12) - 6
- moveAim = alienData[wAlien][3]
- moveDist = 5
- locY = integer(cos(moveAim * PI / 180) * -moveDist)
- locX = integer(sin(moveAim * PI / 180) * moveDist)
- aLoc = aLoc + point(locX, locY)
- if locX > 0 then
- if aLoc[1] > 6000 then
- aLoc[1] = -200
- alienData[wAlien][3] = random(90) + 45
- end if
- else
- if aLoc[1] < -200 then
- aLoc[1] = 6000
- alienData[wAlien][3] = random(90) + 180 + 45
- end if
- end if
- if locY > 0 then
- if aLoc[2] > 4600 then
- aLoc[2] = -200
- alienData[wAlien][3] = random(90) + 45 + 90
- end if
- else
- if aLoc[2] < -200 then
- aLoc[2] = 4600
- alienData[wAlien][3] = (random(90) + 45 + 270) mod 360
- end if
- end if
- alienData[wAlien][2] = aLoc
- maxTimer = (5000 - playerScore) / 50
- if alienData[wAlien][5] > 0 then
- alienData[wAlien][5] = alienData[wAlien][5] - 1
- else
- alienData[wAlien][5] = maxTimer
- addLaser(alienData[wAlien][2], alienData[wAlien][4] + [0, 90, 180, 270][random(4)])
- playSound("Laser SFX", 4)
- end if
- set the loc of sprite wSprite to (aLoc / 10) + bgOffset
- alienData[wAlien][4] = alienData[wAlien][4] + 1
- if alienData[wAlien][4] > 5 then
- alienData[wAlien][4] = 1
- end if
- set the member of sprite wSprite to "Enimy" & string(alienData[wAlien][4])
- end if
- end repeat
- end
-
- on runLasers
- global laserData, laserSO, maxLasers, bgOffset, wTest, playerData, totalLasers
- totalLasers = 0
- repeat with wLaser = 1 to maxLasers
- if laserData[wLaser][1] = 1 then
- totalLasers = totalLasers + 1
- wSprite = wLaser + laserSO - 1
- aLoc = laserData[wLaser][2]
- mloc = playerData[2]
- turnAdjust = random(12) - 6
- moveAim = laserData[wLaser][3]
- moveDist = 50
- locY = integer(cos(moveAim * PI / 180) * -moveDist)
- locX = integer(sin(moveAim * PI / 180) * moveDist)
- aLoc = aLoc + point(locX, locY)
- terminate = 0
- if locX > 0 then
- if aLoc[1] > 6000 then
- terminate = 1
- end if
- else
- if aLoc[1] < -200 then
- terminate = 1
- end if
- end if
- if locY > 0 then
- if aLoc[2] > 4600 then
- terminate = 1
- end if
- else
- if aLoc[2] < -200 then
- terminate = 1
- end if
- end if
- if terminate = 1 then
- laserData[wLaser][1] = 0
- end if
- laserData[wLaser][2] = aLoc
- set the member of sprite wSprite to "Alien Laser"
- sprite(wSprite).rotation = moveAim
- set the loc of sprite wSprite to (aLoc / 10) + bgOffset
- end if
- end repeat
- end
-